package com.itheima.stream流.多种获取方法;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.stream.Stream;

public class Test2 {
    public static void main(String[] args) {
        //method1();
        //method2();
        //  method3();
        // method4();
       ArrayList<String> list5 = new ArrayList<>();
        list5.add("abc");
        list5.add("abc");
        list5.add("bc");
        list5.add("b");
        list5.add("ac");
   list5.stream().filter(s->s.startsWith("c")).forEach(s-> System.out.println(s));

    }

    private static void method4() {
        Stream.of(1, 2, 3, 4, 5, 6).forEach(s -> System.out.println(s));
    }

    private static void method3() {
        int[] arr = {1, 2, 3, 4};
        Arrays.stream(arr).forEach(s -> System.out.println("s"));
    }

    private static void method2() {
        HashMap<String, Integer> hm = new HashMap<>();
        hm.put("a", 1);
        hm.put("ab", 2);
        hm.put("abc", 3);
        //enteySet（）获得所有的键值对对象
        hm.entrySet().stream().forEach(s -> System.out.println(s));
    }

    private static void method1() {
        ArrayList<String> list = new ArrayList<>();
        list.add("a");
        list.add("ab");
        list.add("abc");
        list.stream().forEach(s -> System.out.println(s));
    }
}
